﻿<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
  <class name="EnetaMvc.Core.Domain.Content.ContentItem,EnetaMvc.Core" table="content_item" abstract="true">

    <id name="Id" column="content_item_id" type="long">
      <generator class="identity"/>
    </id>

    <property name="Title" column="title" type="string" />
    <property name="Abstract" column="abstract" type="string" />
    <property name="Body" column="body" type="string" />
    <property name="Created" column="created" type="DateTime" />
    <property name="InfoSourceName" column="info_source_name" type="string" />
    <property name="InfoSourceUrl" column="info_source_url" type="string" />
    <property name="PublishStateDate" column="publish_state_date" type="DateTime" />
    <property name="PublishComment" column="publish_comment" type="string" />

    <many-to-one name="CreatedBy" column="created_by_id" class="EnetaMvc.Core.Domain.Common.User,EnetaMvc.Core" />
    <many-to-one name="PublishState" column="publish_state_id" class="EnetaMvc.Core.Domain.Content.PublishState,EnetaMvc.Core" />
    <many-to-one name="PublishStateBy" column="publish_state_by" class="EnetaMvc.Core.Domain.Common.User,EnetaMvc.Core" />

    <bag name="Tags" table="content_item_tags" inverse="true" cascade="all">
      <key column="content_item_id" />
      <many-to-many class="EnetaMvc.Core.Domain.Content.Tag,EnetaMvc.Core" column="tag_id" />
    </bag>
    <bag name="Comments" table="comments" inverse="true" cascade="all">
      <key column="content_item_id" />
      <one-to-many class="EnetaMvc.Core.Domain.Content.Comment,EnetaMvc.Core" />
    </bag>
  </class>
</hibernate-mapping>